package zerous.mytest;

import android.os.*;
import android.support.design.widget.*;
import android.support.v4.widget.*;
import android.support.v7.app.*;
import android.support.v7.widget.*;
import android.view.*;
import android.view.View.*;
import zerous.mytest.*;
import android.content.*;

public class EditorActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener 
{
	DrawerLayout dl;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_editor);
		
		Toolbar toolbar = (Toolbar)findViewById(R.id.editorToolbar);
		setSupportActionBar(toolbar);
		getSupportActionBar().setHomeButtonEnabled(true);
		
		dl = (DrawerLayout)findViewById(R.id.editorDrawerLayout);

		ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, dl, toolbar, R.string.app_name, R.string.app_name);
		drawerToggle.syncState();
		dl.setDrawerListener(drawerToggle);

		NavigationView navi = (NavigationView)findViewById(R.id.mainNavigation);
		navi.getHeaderView(0).setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					/*
					ft = mgr.beginTransaction();
					ft.replace(R.id.mainFrameLayout, mFrag);
					ft.commit();
					setTitle(R.string.app_name);
					state = Fragments.None;
					*/
					Intent i = new Intent(EditorActivity.this, MainActivity.class);
					i.putExtra("fragments", "main");
					startActivity(i);
					finish();
				}
			}
		);
		navi.setNavigationItemSelectedListener(this);
	}
	
	@Override
	public boolean onNavigationItemSelected(MenuItem item) {
		Intent i = new Intent(this, MainActivity.class);
		switch (item.getItemId()) {
			case R.id.charViewer:
				/*
				ft = mgr.beginTransaction();
				ft.replace(R.id.mainFrameLayout, cvFrag);
				ft.commit();
				setTitle(R.string.char_view);
				state = Fragments.CharView;
				*/
				i.putExtra("fragments", "charViewer");
				startActivity(i);
				finish();
				break;

			case R.id.password:
				/*
				ft = mgr.beginTransaction();
				ft.replace(R.id.mainFrameLayout, pFrag);
				ft.commit();
				setTitle(R.string.password_creator);
				state = Fragments.Password;
				*/
				i.putExtra("fragments", "password");
				startActivity(i);
				finish();
				break;

			case R.id.editor:
				break;

			default:
				return false;
		}
		dl.closeDrawer(Gravity.LEFT);
		return true;
	}
}
